package com.ysw.jdbc;

import java.sql.PreparedStatement;

public class Mysql {
    public static int add(String sql) {

        System.out.println("---------正在执行添加指令-----------");
        int i=0;
        DBConnection db = new DBConnection();
        try {
            PreparedStatement preStmt = (PreparedStatement) db.conn.prepareStatement(sql);
            preStmt.executeUpdate();
            preStmt.close();
            db.close();//
            i = 1;
            System.out.println("---------添加完成-----------");
        } catch (Exception e) {
            System.out.println("---------添加出错-----------");
            e.printStackTrace();
        }
        return i;
    }
}
